package com.wiscamp.ninechapters.tags.infrastructure.converters;

import com.wiscamp.ninechapters.tags.domain.models.Entity;
import com.wiscamp.ninechapters.tags.infrastructure.po.EntityPO;
import com.wiscamp.ninechapters.tags.infrastructure.po.EntityView;
import org.mapstruct.Mapper;
import org.mapstruct.MappingTarget;
import org.mapstruct.NullValuePropertyMappingStrategy;
import org.mapstruct.ReportingPolicy;
import org.mapstruct.factory.Mappers;

@Mapper(componentModel = "spring",
        unmappedTargetPolicy = ReportingPolicy.IGNORE,
        unmappedSourcePolicy = ReportingPolicy.IGNORE,
        nullValuePropertyMappingStrategy = NullValuePropertyMappingStrategy.IGNORE)
public interface EntityConverter {
    EntityConverter Instance = Mappers.getMapper(EntityConverter.class);

    EntityPO toEntityPO(Entity entity);

    EntityPO toEntityPO(Entity entity, @MappingTarget EntityPO po);

    Entity toEntity(EntityPO po);

    Entity toEntityByView(EntityView view);
}
